<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.j2ee.ford.com/fjf-ui" prefix="ui"%>
<%@ taglib uri="ford-arg/tags" prefix="ft" %>
<style type="text/css">
<!--
@import url("./styles/component_selectfromlist.css");

-->
</style>

<!--[if IE]>
	<style type="text/css">
  		@import url("WebContent/styles/component_selectfromlist_iefixes.css");
	</style>
<![endif]-->
<script language="JavaScript" src="./scripts/component_selectfromlist.js" 
        type="text/JavaScript">
</script>

<script language="javascript">
	function commodityQuickSearch(){
		document.CommodityMembersForm.action = "QuickSearchActionFind.do";
		document.CommodityMembersForm.section.value = "quickSearch";
		preprocessAllSelectfromlists();
		document.CommodityMembersForm.submit();
	}
	
	function findParts(){
		document.CommodityMembersForm.action = "CommodityMembersActionFind.do";
		document.CommodityMembersForm.section.value = "find";
		preprocessAllSelectfromlists();
		document.CommodityMembersForm.submit();
	}
	
	function clearLowCom(){
		document.getElementById('lowCom').value="";
	}
	
	function cleanPartSearch(){
		document.getElementById('prefix').value="";
		document.getElementById('base').value="";
		document.getElementById('suffix').value="";
		document.getElementById('partClass').value="-1";
	}
	
	function Save(){
		document.CommodityMembersForm.action = "CommodityMembersActionSave.do";
		document.CommodityMembersForm.section.value = "save";
		preprocessAllSelectfromlists(); //para guardar los seleccionados
		document.CommodityMembersForm.submit();
	}
	
	function Cancel(){
		document.CommodityMembersForm.action = "CommodityMembersActionCancel.do";
		document.CommodityMembersForm.section.value = "";
		preprocessAllSelectfromlists();
		document.CommodityMembersForm.submit();
	}
</script>
<table>
	<tr>
		<td colspan="2"><h2><bean:message key="commodityMembers.label.title"/></h2></td>
	</tr>
</table>
<br/>
<html:form action="/CommodityMembersActionInit">
<html:hidden property="section" />

	<%-- Mantiene el numero de pagina despues del submit --%>
	<ft:saveActivePageNumber/>

	<bean:define id="availableLabel">
		<bean:message key="commodityMembers.selectFromList.label.avaliable" />
	</bean:define>
	<bean:define id="selectedLabel">
		<bean:message key="commodityMembers.selectFromList.label.selected" />
	</bean:define>
	<bean:define id="multipleSelect">
		<bean:message key="commodityMembers.selectFromList.label.multipleSelect" />
	</bean:define>
	<bean:define id="addAllLabel">
		<bean:message key="commodityMembers.selectFromList.label.addAll" />
	</bean:define>
	<bean:define id="addLabel">
		<bean:message key="commodityMembers.selectFromList.label.add" />
	</bean:define>
	<bean:define id="removeLabel">
		<bean:message key="commodityMembers.selectFromList.label.remove" />
	</bean:define>
	<bean:define id="removeAllLabel">
		<bean:message key="commodityMembers.selectFromList.label.removeAll" />
	</bean:define>
	
	<div class="edit_out align_center" style="width: 950px;" >
		<table style="width: 950px;" >
			<tr>
				<td class="text_blue_bold align_left" style="width: 7%">
					<bean:message key="part.label"/>
				</td>
				<td class="text_blue_bold align_right" style="width: 8%">
					<html:select property="partClass" styleId="partClass" onchange="clearLowCom()">
						<html:option value="-1"><bean:message key="label.allOption" /></html:option>
						<html:options collection="partClassColl"
									  property="value"
									  labelProperty="label" />
					</html:select>
				</td>
				<td class="align_right" colspan="2" style="width: 25%">
					<html:text property="prefix" styleId="prefix" maxlength="10" size="10" onclick="clearLowCom()"></html:text>&nbsp;
					<html:text property="base" styleId="base" maxlength="10" size="10" onclick="clearLowCom()"></html:text>&nbsp;
					<html:text property="suffix" styleId="suffix" maxlength="10" size="10" onclick="clearLowCom()"></html:text>&nbsp;
				</td>
				<td style="width: 17%"/>
				<td class="text_blue_bold align_left" style="width: 14%">
					<bean:message key="commodityMemebers.label.quickSearch" />
				</td>
				<td class="text_blue_bold align_left" style="width: 8%">
					<html:text property="commodityCodeFind" styleId="commodityCodeFind" maxlength="4" size="6"></html:text>
				</td>
				<td class="text_blue_bold align_left" style="width: 21%">
					<html:button property="find" onclick="commodityQuickSearch()" styleClass="button_small"><bean:message key="label.find" /></html:button>
				</td>
			</tr>
			<tr>
				<td class="text_blue_bold align_left" colspan="2">
					<bean:message key="commodityMembers.label.lowCom"/>
				</td>
				<td class="align_left">
					<html:text property="lowCom" styleId="lowCom" maxlength="5" size="5" onclick="cleanPartSearch();"></html:text>
				</td>
				<td class="align_right">
					<html:button property="find" onclick="findParts()" styleClass="button_small"><bean:message key="label.find" /></html:button>
				</td>
				<td style="width: 10%"/>
				<td class="text_blue_bold align_left" colspan="3">
					<bean:message key="commodity.label" />:&nbsp;
					<bean:write name="CommodityMembersForm" property="commodityCode"/>&nbsp;&minus;&nbsp;<bean:write name="CommodityMembersForm" property="commodityName"/>
				</td>
			</tr>
		</table>
	</div>	
	<br/>
	<ui:selectFromList name="CommodityMembersForm" property="selectedParts" 
		 	    availableLabel="${availableLabel}" 
		 	    selectedLabel="${selectedLabel}"
		 	    sort="desc" size="10" bundle="resources.messagesResources">
		 	    
		<ui:allOptions name="optionParts" label="label" value="value" />
		
		<ui:selectFromListButtons includeAllButtons="true" addAllLabel="${addAllLabel}" addLabel="${addLabel}" 
						removeAllLabel="${removeAllLabel}" removeLabel="${removeLabel}"/>
	</ui:selectFromList>
	<table style="width: 950px;">
		<tr>
			<td style="width: 60%"/>
			<td class="align_center" style="width: 20%">
				<html:button property="find" onclick="Save()" styleClass="button_small"><bean:message key="label.save" /></html:button>
			</td>
			<td class="align_center" style="width: 20%">
				<html:button property="find" onclick="Cancel()" styleClass="button_small"><bean:message key="label.cancel" /></html:button>
			</td>
		</tr>
	</table>
		
</html:form>